<?php
	include "share.php";

	if($_SERVER['REQUEST_METHOD'] == "GET"){
		$results = mysqli_query($conn,"SELECT username FROM users WHERE username='$_GET[username]'");
		$row =  mysqli_num_rows($results);
		if($row!=1){
			echo "1";
		}else{
			echo "0";
		};
	}else if($_SERVER['REQUEST_METHOD'] == "POST"){
		$date = time();
		$result = mysqli_query($conn,"SELECT username FROM users WHERE username='$_POST[username]'");
		$rows =  mysqli_num_rows($result);
		if($rows!=1){
			$record = mysqli_query($conn,"INSERT INTO users (username,password,status,createtime) VALUES('$_POST[username]','$_POST[password]','1',now())");
			if($record){
				echo "1";
			}else{
				echo "0";
			};
		}else{
			echo "0";
		};
	};
?>